import {defineStore} from 'pinia'
import {ref} from 'vue'
import { getCartList } from '../api'

export default defineStore('store2',()=>{
    let num=ref(0)
    let goodsData = ref([])
   

    function getCartInfo(){
        getCartList({page:1,limit:100}).then(res=>{
            if(res.code==1){
                num.value=res.data.count
                goodsData.value=res.data.list
              
            }
        })
    }

    function clearCartInfo(){
       num.value=0
        goodsData.value=[]
    }

    return{
        num,goodsData,getCartInfo,clearCartInfo
    }
})